// #获取time
// (function () {
//   let timer = document.querySelectorAll(".timer ");
//   let date = new Date();
//   let year = date.getFullYear();
//   let month = date.getMonth() + 1;
//   let day = date.getDay();
//   // console.log(year + "-" + month + "-" + day);
//   for (let i = 0; i < timer.length; i++) {
//     timer[i].innerHTML = year + "-" + month + "-" + day;
//   }
//   // timer.innerHTML = year + "-" + month + "-" + day;
// })();
// 图1
(function () {
  // 线图轨迹。 0=》无，1=》外到内，2=》内到外，3 =》 双向
  let myCharts = echarts.init(document.querySelector(".bar .chart "));

  let points = [
    {
      name: "淘宝",
      desc: {
        type: 3,
      },
    },
    {
      name: "京东",
      desc: {
        type: 2,
      },
    },
    {
      name: "拼多多",
      desc: {
        type: 1,
      },
    },
    {
      name: "天猫",
      desc: {
        type: 3,
      },
    },
    {
      name: "唯品会",
      desc: {
        type: 2,
      },
    },
    {
      name: "苏宁易购",
      desc: {
        type: 1,
      },
    },
  ];
  let color = ["#ffffff", "#36fff6", "#ffe93a", "#67f95f"];
  let oneArr = [
    {
      name: "中心点",
      desc: {
        type: 0,
      },
      symbol: "none",
      symbolSize: 233,
    },
  ];
  let erArr = points;
  let allArr = [...oneArr, ...erArr],
    dataArr = [];
  // 点
  allArr.forEach((el, ind) => {
    if (el.desc.type > 0) {
      el.symbolSize = 50;
      el.symbol =
        "path://M544 552.325V800a32 32 0 0 1-32 32 31.375 31.375 0 0 1-32-32V552.325L256 423.037a32 32 0 0 1-11.525-43.512A31.363 31.363 0 0 1 288 368l224 128 222.075-128a31.363 31.363 0 0 1 43.525 11.525 31.988 31.988 0 0 1-11.525 43.513L544 551.038z m0 0,M64 256v512l448 256 448-256V256L512 0z m832 480L512 960 128 736V288L512 64l384 224z m0 0";
      el.itemStyle = {
        color: color[el.desc.type],
      };
    }
    el.label = {
      normal: {
        show: true,
        position: "bottom",
        distance: 10,
        color: color[el.desc.type],
      },
    };
  });

  // 圆形分区
  function CalutePointToSplitCircle(arr, option) {
    const newArray = [];
    const { length: arLen } = arr;
    let single_angle = (360 / arLen).toFixed(2);
    let UtilCalute = {
      calute_x: (ang, radius) => {
        return (Math.cos((ang * Math.PI) / 180).toFixed(2) * radius).toFixed(2);
      },
      calute_y: (ang, radius) => {
        return (Math.sin((ang * Math.PI) / 180).toFixed(2) * radius).toFixed(2);
      },
    };
    // 正东方向开始 逆时针方向
    arr.forEach((e, index) => {
      let itemDesc = e.desc;
      let ang =
        option.stratAngle +
        (itemDesc.angle && typeof itemDesc.angle === "number"
          ? itemDesc.angle
          : single_angle * index);
      // 各节点中心点
      const x = UtilCalute.calute_x(ang, option.raduis);
      const y = UtilCalute.calute_y(ang, option.raduis);
      // 各节点连接到中心的线段的起点  减去节点的半径
      const x1 = UtilCalute.calute_x(ang, option.raduis - option.nodeRadius);
      const y1 = UtilCalute.calute_y(ang, option.raduis - option.nodeRadius);
      // 各节点连接到中心的线段的终点
      const x0 = UtilCalute.calute_x(ang, option.emptyCenterRadius);
      const y0 = UtilCalute.calute_y(ang, option.emptyCenterRadius);

      e.value = [x, y]; // 节点中心点
      e.lineData = [
        [x1, y1],
        [x0, y0],
      ];
      newArray.push(e);
    });
    return newArray;
  }

  // 线配置
  function linesConfig(arr) {
    let dataArr = [];

    function getFormatItem(item, start, end) {
      return [
        { coord: item.lineData[start] }, // 起点
        {
          coord: item.lineData[end],
          lineStyle: {
            color: "#0BC6FE",
            curveness: item.desc.type === 3 ? 0.1 : 0,
          },
          effect: {
            color: color[item.desc.type],
          },
        }, // 终点
      ];
    }

    arr.forEach((el) => {
      switch (el.desc.type) {
        case 0:
          break;
        case 1:
          // 外到内
          dataArr.push(getFormatItem(el, 0, 1));
          break;
        case 2:
          // 内到外
          dataArr.push(getFormatItem(el, 1, 0));
          break;
        case 3:
          // 双向
          dataArr.push(getFormatItem(el, 0, 1));
          dataArr.push(getFormatItem(el, 1, 0));
          break;
      }
    });
    return dataArr;
  }

  // 点分布
  oneArr = CalutePointToSplitCircle(oneArr, {
    stratAngle: 0,
    raduis: 0,
    nodeRadius: 0,
    emptyCenterRadius: 0,
  });
  erArr = CalutePointToSplitCircle(erArr, {
    stratAngle: 0,
    raduis: 40,
    nodeRadius: 5,
    emptyCenterRadius: 10,
  });

  allArr = [...oneArr, ...erArr];
  // 线坐标和配置
  dataArr = linesConfig(allArr);
  // 生成虚线 饼图数据
  function generateData(totalNum, bigvalue, smallvalue, color) {
    let dataArr = [];
    for (let i = 0; i < totalNum; i++) {
      if (i % 2 === 0) {
        dataArr.push({
          name: (i + 1).toString(),
          value: bigvalue,
          itemStyle: {
            normal: {
              color: color,
              borderWidth: 0,
            },
          },
        });
      } else {
        dataArr.push({
          name: (i + 1).toString(),
          value: smallvalue,
          itemStyle: {
            normal: {
              color: "rgba(0,0,0,0)",
              borderWidth: 0,
            },
          },
        });
      }
    }
    return dataArr;
  }

  let dolitData = generateData(100, 25, 20, "rgb(126,190,255)");
  let threeData = generateData(6, 40, 10, "#2dc0c9");

  function getOption(startAngle, radius) {
    let option = {
      xAxis: {
        show: false,
        type: "value",
        max: 50,
        min: -51,
      },
      grid: {
        top: 0,
        bottom: 10,
        left: 10,
        right: 10,
      },
      yAxis: {
        show: false,
        type: "value",
        max: 50,
        min: -50,
      },
      graphic: {
        elements: [
          {
            type: "text",
            z: 7,
            style: {
              text: "大数据",
              textAlign: "center",
              fill: "#fff",
              font: '30px "Microsoft YaHei"',
            },
            left: "center",
            top: "center",
          },
          {
            type: "image",
            z: 4,
            style: {
              image: "./asset/get/s/data-1641374427371-xPKsRNQ2l.png",
              width: 170,
              height: 170,
            },
            left: "center",
            top: "center",
          },
        ],
      },
      series: [
        {
          name: "节点",
          type: "graph",
          silent: false,
          hoverAnimation: false, // 鼠标悬浮高亮
          cursor: "default",
          coordinateSystem: "cartesian2d",
          z: 3,
          lineStyle: {
            width: 2,
            color: "source",
            type: "dashed",
          },
          data: allArr,
        },
        {
          name: "线图",
          type: "lines",
          hoverAnimation: false,
          silent: false,
          cursor: "default",
          coordinateSystem: "cartesian2d",
          polyline: false, // 多线段
          z: 1,
          lineStyle: {
            width: 2,
            type: "dashed",
            curveness: 0,
          },
          effect: {
            show: true,
            period: 8, //箭头指向速度，值越小速度越快
            trailLength: 0, //特效尾迹长度[0,1]值越大，尾迹越长重
            symbol: "arrow", //箭头图标
            symbolSize: 6,
          },
          emphasis: {
            lineStyle: {
              type: "dashed",
            },
          },
          data: dataArr,
        },
        {
          name: "不动外圆",
          type: "pie",
          zlevel: 4,
          silent: true,
          radius: ["60%", "59%"],
          label: {
            normal: {
              show: false,
            },
          },
          labelLine: {
            normal: {
              show: false,
            },
          },
          data: dolitData,
        },
        {
          type: "pie",
          name: "旋转圆",
          zlevel: 20,
          silent: true,
          radius: ["50%", "49%"],
          hoverAnimation: false,
          startAngle: startAngle,
          data: threeData,
          label: {
            normal: {
              show: false,
            },
          },
          labelLine: {
            normal: {
              show: false,
            },
          },
        },
        {
          name: "缩放圆",
          type: "pie",
          zlevel: 4,
          silent: true,
          radius: [radius + 1 + "%", radius + "%"],
          label: {
            normal: {
              show: false,
            },
          },
          labelLine: {
            normal: {
              show: false,
            },
          },
          data: dolitData,
        },
      ],
    };
    return option;
  }

  let startAngle = 50; // 初始旋转角度
  let [minradius, radius, maxradius] = [22, 22, 24]; // 最小、初始、最大 缩放尺寸
  let isBig = true; // 缩放动画 标识

  function draw() {
    startAngle = startAngle - 5;
    if (isBig) {
      radius = radius + 0.5;
      if (radius > maxradius) {
        isBig = false;
      }
    } else {
      radius = radius - 0.5;
      if (radius < minradius) {
        isBig = true;
      }
    }
    let option = getOption(startAngle, radius);
    myCharts.setOption(option, true);
  }

  timer = setInterval(draw, 200);
  window.addEventListener("resize", function () {
    myCharts.resize();
  });
})();
// 图 散点图
(function () {
  let myCharts = echarts.init(document.querySelector(".pie2 .chart"));
  //这两个数组用于存储数据
  let womens = [];
  let mens = [];
  //使用ajax发送数据
  $.post("http://124.220.134.135:8883/getAgeGenders", function (responseData) {
    //当后端返回的code为0时，则给出弹出框
    if (responseData.code === '0') {
      alert(responseData.msg);
      return;
    }
    // 遍历数据
    for (let i = 0; i < responseData.data.length; i++) {
      if (responseData.data[i].gender == '0') {
        let women = [];
        responseData.data[i].gender = "women";
        women.push(responseData.data[i].age_range);
        women.push(responseData.data[i].num);
        women.push(responseData.data[i].gender);
        womens.push(women)

      }
      else {
        let men = [];
        responseData.data[i].gender = "men";
        men.push(responseData.data[i].age_range);
        men.push(responseData.data[i].num);
        men.push(responseData.data[i].gender);
        mens.push(men)
      }
    }
    console.log(responseData.data);
    console.log(womens);
    console.log(mens);


    //设置图表参数
    option = {
      backgroundColor: new echarts.graphic.RadialGradient(0.3, 0.3, 0.8, [
        {
          offset: 0,
          color: '#f7f8fa'
        },
        {
          offset: 1,
          color: '#cdd0d5'
        }
      ]),

      legend: {
        right: '10%',
        top: '0%',
      },
      grid: {
        left: '8%',
        top: '10%'
      },
      xAxis: {
        splitLine: {
          lineStyle: {
            type: 'dashed'
          }
        }
      },
      yAxis: {
        splitLine: {
          lineStyle: {
            type: 'dashed'
          }
        },
        scale: true
      },
      series: [
        {
          name: 'women',
          data: womens,
          type: 'scatter',


          itemStyle: {
            shadowBlur: 10,
            shadowColor: 'rgba(120, 36, 50, 0.5)',
            shadowOffsetY: 5,
            color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [
              {
                offset: 0,
                color: 'rgb(251, 118, 123)'
              },
              {
                offset: 1,
                color: 'rgb(204, 46, 72)'
              }
            ])
          }
        },
        {
          name: 'men',
          data: mens,
          type: 'scatter',


          itemStyle: {
            shadowBlur: 10,
            shadowColor: 'rgba(25, 100, 150, 0.5)',
            shadowOffsetY: 5,
            color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [
              {
                offset: 0,
                color: 'rgb(129, 227, 238)'
              },
              {
                offset: 1,
                color: 'rgb(25, 183, 207)'
              }
            ])
          }
        }
      ]
    };
    //渲染图表
    myCharts.setOption(option);
    window.addEventListener("resize", function () {
      myCharts.resize();
    });
  }, "json");


})();

// 图三
(function () {

  let myCharts = echarts.init(document.querySelector(".line .chart"));
  //使用ajax发送数据
  //这两个数组用于存储数据
  let action = [];
  let num = [];
  //使用ajax发送数据
  $.post("http://ganxinmin.cn:8883/getActions", function (responseData) {
    //当后端返回的code为0时，则给出弹出框
    if (responseData.code === '0') {
      alert(responseData.msg);
      return;
    }
    //遍历数据
    for (let i = 0; i < responseData.data.length; i++) {
      action.push(responseData.data[i].action);
      num.push(responseData.data[i].num);
    }
    let nameArr = ["特别关注", "购买", "添加购物车", "点击"]
    for (let i = 0; i < action.length; i++) {
      action[i] = nameArr[i];
    }
    console.log("adada", action);
    console.log("sadada", num);
    let angle = 0;//角度，用来做简单的动画效果的
    let value = 55.33;
    option = {
      color: ["#EAEA26", "#906BF9", "#FE5656", "#01E17E"],

      grid: {
        left: -300,
        top: -2250,
        bottom: 10000,
        right: 0,
        containLabel: true
      },
      tooltip: {
        trigger: 'item',
        formatter: "{b} : {c} ({d}%)"
      },
      legend: {
        type: "scroll",
        // orient: "vartical",
        // x: "right",
        top: "bottom",
        left: "20%",
        bottom: '0',
        // bottom: "0%",
        itemWidth: 16,
        itemHeight: 8,
        itemGap: 16,
        textStyle: {
          color: '#A3E2F4',
          fontSize: 12,
          fontWeight: 0
        },
        data: action
      },
      polar: {},
      angleAxis: {
        interval: 1,
        type: 'category',
        data: [],
        z: 10,
        axisLine: {
          show: false,
          lineStyle: {
            color: "#0B4A6B",
            width: 1,
            type: "solid"
          },
          symbolSize: [10, 10]
        },
        axisLabel: {
          interval: 0,
          show: true,
          color: "#0B4A6B",
          margin: 8,
          fontSize: 16
        },
      },
      radiusAxis: {
        boundaryGap: true,
        radius: ["70%", "75%"],
        axisLine: {
          show: false,
          lineStyle: {
            color: "#0B3E5E",
            width: 1,
            type: "solid"
          },
          symbolSize: [10, 10]
        },
        axisLabel: {
          formatter: '{value} %',
          show: false,
          padding: [0, 0, 20, 0],
          color: "#0B3E5E",
          fontSize: 16
        },
        splitLine: {
          lineStyle: {
            color: "#0B3E5E",
            width: 2,
            type: "solid"
          }
        }
      },
      calculable: true,
      series: [{
        name: "ring5",
        type: 'custom',
        coordinateSystem: "none",
        renderItem: function (params, api) {
          return {
            type: 'arc',
            shape: {
              cx: api.getWidth() / 2,
              cy: api.getHeight() / 2,
              r: Math.min(api.getWidth(), api.getHeight()) / 2 * 0.6,
              startAngle: (180 + angle) * Math.PI / 180,
              endAngle: (270 + angle) * Math.PI / 180
            },
            style: {
              stroke: "#0CD3DB",
              fill: "transparent",
              lineWidth: 1.5
            },
            silent: true
          };
        },

      }, {
        name: "ring5",
        type: 'custom',
        coordinateSystem: "none",
        renderItem: function (params, api) {
          return {
            type: 'arc',
            shape: {
              cx: api.getWidth() / 2,
              cy: api.getHeight() / 2,
              r: Math.min(api.getWidth(), api.getHeight()) / 2 * 0.65,
              startAngle: (270 + -angle) * Math.PI / 180,
              endAngle: (40 + -angle) * Math.PI / 180
            },
            style: {
              stroke: "#0CD3DB",
              fill: "transparent",
              lineWidth: 1.5
            },
            silent: true
          };
        },
        data: [0]
      }, {
        name: "ring5",
        type: 'custom',
        coordinateSystem: "none",
        renderItem: function (params, api) {
          return {
            type: 'arc',
            shape: {
              cx: api.getWidth() / 2,
              cy: api.getHeight() / 2,
              r: Math.min(api.getWidth(), api.getHeight()) / 2 * 0.65,
              startAngle: (90 + -angle) * Math.PI / 180,
              endAngle: (220 + -angle) * Math.PI / 180
            },
            style: {
              stroke: "#0CD3DB",
              fill: "transparent",
              lineWidth: 1.5
            },
            silent: true
          };
        },

      }, {
        name: "ring5",
        type: 'custom',
        coordinateSystem: "none",
        renderItem: function (params, api) {
          let x0 = api.getWidth() / 2;
          let y0 = api.getHeight() / 2;
          let r = Math.min(api.getWidth(), api.getHeight()) / 2 * 0.65;
          let point = getCirlPoint(x0, y0, r, (90 + -angle))
          return {
            type: 'circle',
            shape: {
              cx: point.x,
              cy: point.y,
              r: 4
            },
            style: {
              stroke: "#0CD3DB",//粉
              fill: "#0CD3DB"
            },
            silent: true
          };
        },

      }, {
        name: "ring5",  //绿点
        type: 'custom',
        coordinateSystem: "none",
        renderItem: function (params, api) {
          let x0 = api.getWidth() / 2;
          let y0 = api.getHeight() / 2;
          let r = Math.min(api.getWidth(), api.getHeight()) / 2 * 0.65;
          let point = getCirlPoint(x0, y0, r, (270 + -angle))
          return {
            type: 'circle',
            shape: {
              cx: point.x,
              cy: point.y,
              r: 4
            },
            style: {
              stroke: "#0CD3DB",      //绿
              fill: "#0CD3DB"
            },
            silent: true
          };
        },

      }, {
        type: 'pie',
        radius: ["5%", "10%"],
        hoverAnimation: false,
        id: 40,
        labelLine: {
          normal: {
            show: false,
            length: 30,
            length2: 55
          },
          emphasis: {
            show: false
          }
        },
        data: [{
          name: '',
          value: 0,
          itemStyle: {
            normal: {
              color: "#0B4A6B"
            }
          }
        }]
      }, {
        type: 'pie',
        radius: ["70%", "75%"],
        hoverAnimation: false,
        id: 30,
        labelLine: {
          normal: {
            show: false,
            length: 30,
            length2: 55
          },
          emphasis: {
            show: false
          }
        },
        name: "",
        data: [{
          name: '',
          value: 0,
          itemStyle: {
            normal: {
              color: "#0B4A6B"
            }
          }
        }]
      }, {
        stack: 'a',
        type: 'pie',
        radius: ['20%', '60%'],
        roseType: 'area',
        zlevel: 10,
        id: 50,
        label: {
          normal: {
            show: true,
            formatter: "{c}",
            textStyle: {
              fontSize: 12,
            },
            position: 'outside'
          },
          emphasis: {
            show: true
          }
        },
        labelLine: {
          normal: {
            show: true,
            length: 20,
            length2: 55
          },
          emphasis: {
            show: false
          }
        },
        data: [{
          value: num[0],
          name: action[0]
        },
        {
          value: num[1],
          name: action[1]
        },
        {
          value: num[2],
          name: action[2]
        },
        {
          value: num[3],
          name: action[3]
        },

        ]
      },]
    }


    //获取圆上面某点的坐标(x0,y0表示坐标，r半径，angle角度)
    function getCirlPoint(x0, y0, r, angle) {
      let x1 = x0 + r * Math.cos(angle * Math.PI / 180)
      let y1 = y0 + r * Math.sin(angle * Math.PI / 180)
      return {
        x: x1,
        y: y1
      }
    }

    function Rotate() {
      angle = angle + 5;
      myCharts.setOption(option, true);
      //window.requestAnimationFrame(draw);
    }

    setInterval(() => {
      //用setInterval做动画感觉有问题
      Rotate();
    }, 100);
    myCharts.setOption(option, true);
  }, "json");

  window.addEventListener("resize", function () {
    myCharts.resize();
  });
})();

// 图4
(function () {

  let myCharts = echarts.init(document.querySelector(".line2 .chart"));
  //这两个数组用于存储数据
  let name = [];
  let num = [];
  //使用ajax发送数据
  $.post("http://ganxinmin.cn:8883/getVolumes", function (responseData) {
    //当后端返回的code为0时，则给出弹出框
    if (responseData.code === '0') {
      alert(responseData.msg);
      return;
    }
    //遍历数据
    for (let i = 0; i < responseData.data.length; i++) {
      name.push(responseData.data[i].name);
      name[i] = `类别${i + 1}`;

      num.push(responseData.data[i].num);
    }
    console.log(name);
    console.log(num);
    //设置图表参数
    //觉得好可以点个赞哦！
    option = {
      grid: {
        left: "5%",
        right: "5%",
        bottom: "-5%",
        top: "0%",
        containLabel: true,
      },


      xAxis: {
        show: false,
        type: "value",
      },
      yAxis: [
        {
          type: "category",
          inverse: true,
          axisLabel: {
            show: true,
            textStyle: {
              color: "#fff",
            },
          },
          splitLine: {
            show: false,
          },
          axisTick: {
            show: false,
          },
          axisLine: {
            show: false,
          },
          data: name,
        },
        {
          type: "category",
          inverse: true,
          axisTick: "none",
          axisLine: "none",
          show: true,
          axisLabel: {
            textStyle: {
              color: "#ffffff",
              fontSize: "12",
            },

          },
          data: num,
        },
      ],
      series: [
        {
          name: "数量",
          type: "bar",
          zlevel: 1,
          itemStyle: {
            normal: {
              barBorderRadius: 30,
              color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
                {
                  offset: 0,
                  color: "rgb(57,89,255,1)",
                },
                {
                  offset: 1,
                  color: "rgb(46,200,207,1)",
                },
              ]),
            },
          },
          barWidth: 20,
          data: num,
        },

      ],
    };
    //渲染图表
    myCharts.setOption(option);
  }, "json");
  window.addEventListener("resize", function () {
    myCharts.resize();
  });
})();

// 图五

(function () {
  let myCharts = echarts.init(document.querySelector(".pie .chart"));
  let gender = [];
  let num = [];

  // 通过Ajax获取数据
  // 获取数据
  $.post("http://ganxinmin.cn:8883/getGenders", (responseData) => {
    responseData.data.forEach((item, index) => {
      let s = '';
      if (item.gender === '0') {
        s = "女";
      }
      if (item.gender === '1') {
        s = "男";
      }

      gender.push(s);
      num.push(item.num);
    });

    option = {
      // 提示框组件的设置
      tooltip: {
        // 触发类型
        trigger: 'axis',
        axisPointer: {
          type: 'none'
        },
        // 设置文本内容格式
        formatter: function (params) {
          return params[0].name + ': ' + params[0].value;
        }
      },
      // x轴
      xAxis: {
        // x轴的数据
        data: gender,
        // x轴的刻度
        axisTick: {
          show: false
        },
        axisLine: {
          show: false
        },
        axisLabel: {
          color: '#fff'
        }
      },
      // y轴
      yAxis: {
        splitLine: {
          show: false
        },
        axisTick: {
          show: false
        },
        axisLine: {
          show: false
        },
        axisLabel: {
          show: false
        }
      },
      // 网格组件的设置
      grid: {
        left: '10%',
        right: '10%',
        top: '10%',
        bottom: '6',
        containLabel: true
      },
      // 图表组件的设置
      series: [{
        // 图表类型
        type: 'pictorialBar',
        barCategoryGap: '-50%',
        symbol: 'path://M0,10 L10,10 C5.5,10 5.5,5 5,0 C4.5,5 4.5,10 0,10 z',
        // 对图表中每一项进行样式设置
        itemStyle: {
          opacity: 0.3,
          normal: {
            color(params) {
              let colorList = ['pink', '#2F54EB']
              return colorList[params.dataIndex]
            },
          },
        },
        // 高亮设置
        emphasis: {
          itemStyle: {
            opacity: 1,
          }
        },
        data: num,
        z: 10
      }]
    };

    myCharts.setOption(option);
  }, "json");
  window.addEventListener("resize", function () {
    myCharts.resize();
  });
})();




// 数字模块1
(function () {
  // 市场需求人数
  let need = document.querySelector(".no-hd").querySelectorAll("li")[0];
  // 市场供应人数
  let supply = document.querySelector(".no-hd").querySelectorAll("li")[1];
  function getRandomInt(min, max) {
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min;
  }

  function needSum() {
    need.innerHTML = parseInt(need.innerHTML) + getRandomInt(1, 10);
    // ***************

    localStorage.setItem("lastname", need.innerHTML);
    // Retrieve
    need.innerHTML = localStorage.getItem("lastname");
    // console.log(localStorage.getItem("lastname"));

    // *************
  }
  function supplySum() {
    supply.innerHTML = parseInt(supply.innerHTML) + getRandomInt(1, 10);
  }
  setInterval(needSum, 1500);
  setInterval(supplySum, 2000);
})();

// 三个点击按钮
(function () {
  let but1 = document.querySelector(".buttons .but1");
  // let but2 = document.querySelector(".buttons .but2");
  // let but3 = document.querySelector(".buttons .but3");
  // let but4 = document.querySelector(".buttons .but4");
  // let mainbox = document.querySelector(".mainbox");
  // let mainbox2 = document.querySelector(".mainbox2");
  // $(mainbox2).hide();
  but1.addEventListener("click", function () {
    // $(mainbox2).hide();
    // $(mainbox2).hide();
    // $(mainbox).show();

    window.location.href = "./index.html";
  });
  // but2.addEventListener("click", function () {
  //   // window.location.href = "./屏幕2.html";
  //   // alert("小甘正在努力开发中...")
  //   // location.reload();
  //   // $(mainbox).hide();
  //   // $(mainbox2).show();
  //   // $("<li><li>");

  // });
  $('.buttons .but2').on('click', function () {
    //捕获页
    layer.msg('小甘正在努力开发中,敬请期待...', { time: 3000, icon: 6 });

  })
  $('.buttons .but3').on('click', function () {
    //捕获页
    layer.msg('小甘正在努力开发中,敬请期待...', { time: 3000, icon: 6 });

  })
  $('.buttons .but4').on('click', function () {
    //捕获页
    layer.msg('小甘正在努力开发中,敬请期待...', { time: 3000, icon: 6 });

  })
})();

